function R=downsampled(I)
[rows,cols]=size(I);
T=zeros(rows/2,cols/2);

for i=1:2:rows
  for j=1:2:cols
    suma=(I(i,j)+I(i,j+1)+I(i+1,j)+I(i+1,j+1));
    T(floor(i/2)+1,floor(j/2+1))=suma/4;
  end
end

R=T;



end